 <?php
    $opt ="";
    
    
    if(!empty($colors)){
        if(!empty($option))
        {
            $opt = $colors['options']['colors'][$option]['size'];
            var_dump($opt);
        }   
    }
 ?>
 <?php echo form_open_multipart('administrator/shop/product/save'); ?>
<div class="" id="myModal" >
  <div class="modal-header">
    <h3 style="text-transform: capitalize;"><?php echo $action ?> Product <?php echo $product_title[$this->session->userdata('lan')]['product_name'] ?></h3>
  </div>
 <table class="table table-striped table-bordered table-condensed">
    <tr id="options">
        <td><label>Màu sắc</label><input type="text" name="color" value="<?php echo $opt?>" /><br/><a id="addsize" href="javascript:;">Thêm size</a></td>
        
    </tr>
 </table>
 <?php
    if(!empty($option)):?>
        <?php if(!empty($colors['options']['colors'][$opt]['images'])): foreach($colors['options']['colors'][$opt]['images'] as $key=>$val):?>
            <div class="thumbnails" style="float: left;">
                 
                    <li class="span2">
                    <label for="checkbox" class="checkbox">
                    <input type="checkbox" name="images[]" id="name" value="<?php echo $val?>" />Delete</label>
                    <a href="<?php echo site_url().$val ?>" class="thumbnail">
                        <img src="<?php echo $this->config->item('cdn_url') ?>exec/timthumb.php?src=<?php echo site_url().$val ?>&h=120&w=160&zc=1" alt=""/>
                    </a></li>
                 </div>
        <?php endforeach; endif;?>
    <?php endif;?>
 <div style="clear: both;"></div>
 <p><a href="javascript:;" title="Add more images" id="add_more" class="btn"><i class="icon-plus"></i> Add more image</a></p>
 <div id="image_field">
     <div>
        <label><strong>Hình 1</strong><em>(Hình mặc định khi vào xem sản phẩm)</em></label><input class="input-file" type="file" id="userfile1" name="userfile1" />
    </div>
 </div>
<div class="modal-footer">
    <input type="submit" class="btn btn-primary"  value="Save"/>
    <a href="<?php echo base_url().'/administrator/shop/product/'?>" class="btn">Cancel</a>
    <textarea name="product_detail" style="display: none;"><?php echo $product->product_detail; ?></textarea>
    <input type="text" name="color_tag" value="<?php echo $product->color_tag; ?>" />
    <input type="text" name="size_tag" value="<?php echo $product->size_tag; ?>" />
    <input type="hidden" name="action"  value="<?php  echo $action ?>" id="action" />
    <input type="hidden" name="product_id"  value="<?php  echo $product_id ?>" id="action" />
  </div>   
</div>
</form>
<div class="row-fluid">

    <?php
    $tabs= "";
    $tabs_content="";
    
    if(!empty($colors)){
        
        foreach($colors['options']['colors'] as $key=>$values){
            $tabs.=" <li><a href='#".$key."' data-toggle=\"tab\">".strtoupper($key)."</a></li>";
            $tabs_content.="<div class='tab-pane' id='".$key."'><p>".anchor('administrator/shop/product/detail/'.$product_id.'/'.$key,'<i class="icon-cog"></i> Edit','class=btn')."</p><table width=100%><tr>";
            if(!empty($values['size'])): 
                foreach($values['size'] as $key=>$val):
                    $tabs_content.="<td><label>Số lượng size ".$key."</label><input name='".$key."' value='".$val."' type=\"text\" class=\"input-small\" /></td>";
                endforeach;
            endif;
            $tabs_content.="</tr></table>";
              if(!empty($values['images'])):
                foreach($values['images'] as $key=>$val):            
                $tabs_content.='<div class="thumbnails" style="float:left">';
                    $tabs_content.='<li class="span2">';
                    $tabs_content.='<a href="#" class="thumbnail">';
                    $tabs_content.='<img src='.$this->config->item('cdn_url').'exec/timthumb.php?src='.site_url().$val.'&h=120&w=160&zc=1" alt=""/>';
                    $tabs_content.='</a></li></div>';
                endforeach;
            endif;
            $tabs_content.="<div style='clear:both'></div>";
            $tabs_content.="</div>";
          
        }
    }
    ?>
<ul class="nav nav-tabs">
    <?php echo $tabs; ?>
</ul>
<div class="tab-content">
 <?php echo $tabs_content; ?>
</div>
    </div>